home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / TestParts / Draw / PrtPrpAc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-01  |  27.9 KB  |  879 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PrtPrpAc.cpp
  3.  
  4.     Contains:    Implemementation of DrawPartPropAccessor class.
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <11>      9/4/95    TJ        Added Includes to Compile with out
  13.                                     PC-Headers.
  14.         <10>      8/7/95    NP        Added a comment.
  15.          <9>     6/30/95    JP        Refcounting foo
  16.          <8>     6/26/95    JBS        &DMc&TÇ 1242642 BB: Refcounting Fixes.
  17.          <7>     6/22/95    jpa        Fixed typedefs to give correct data size.
  18.                                     [1261644]
  19.          <6>     5/26/95    RR        #1251403: Multithreading naming support
  20.          <5>     3/24/95    eeh        1232264: use ODFrame* rather than ODPart*
  21.                                     to keep track of parts
  22.          <4>     1/25/95    jpa        Renamed SOM class to Container [1213318]
  23.          <3>     9/29/94    RA        1189812: Mods for 68K build.
  24.          <2>     9/22/94    JBS        1188214: coordinate bias implementation
  25.          <1>     8/30/94    NP        first checked in
  26.          <4>      4/6/94    JBS        1155477
  27.          <3>     3/25/94    JA        GetPlatformTransform -> GetQDOffset
  28.                                     (1153438).
  29.          <2>     2/16/94    JA        Include new AltPoint.h.
  30.         <14>      2/8/94    TÇ        Throw -> THROW & some code clean up
  31.         <13>      2/7/94    TÇ        fixes to compile with PPC Headers
  32.         <12>     1/19/94    eeh        removed assert from GetDrawPart; fixed
  33.                                     G/SetData param types
  34.         <11>     1/11/94    eeh        bounds property; removing "frame" from
  35.                                     ospec vocabulary
  36.         <10>    12/17/93    eeh        more work on setting bounds property of
  37.                                     frame
  38.          <9>    12/15/93    JBS        use new clipShape calls
  39.          <8>     12/9/93    eeh        implement classes AbsDrawPartPropAccessor,
  40.                                     DragPartPropAccessor and FramePropAccessor
  41.          <7>     12/1/93    CG        Added new class EmbeddedPartPropAccessor
  42.                                     for getting pBounds and pTranslation from
  43.                                     an embedded part.
  44.          <6>    11/22/93    SS        Added typecast for lastest headers
  45.          <5>    11/16/93    CG        Added some code to GetData.
  46.          <4>    11/12/93    JBS        use Facets
  47.          <3>     11/2/93    NP        Cast kODNULL to proper type.
  48.          <2>     9/14/93    NP        Explicitly set port to frame's window
  49.                                     before calling invalidate.
  50.          <1>     9/10/93    NP        first checked in
  51.  
  52.     To Do:
  53.     In Progress:
  54.         Fixed RGBColor parameters to methods.
  55. */
  56.  
  57. #ifndef _ALTPOINT_
  58. #include "AltPoint.h"            // Use C++ savvy ODPoint and ODRect
  59. #endif
  60.  
  61.  
  62. #ifndef _PRTPRPAC_
  63. #include "PrtPrpAc.h"
  64. #endif
  65.  
  66. #ifndef _DRWSHARED_
  67. #include "DrwShared.h"
  68. #endif
  69.  
  70. #ifndef SOM_ODDraft_xh
  71. #include <Draft.xh>
  72. #endif
  73.  
  74. #ifndef SOM_Module_AppleTestDraw_defined
  75. #include "DrawPart.xh"
  76. #endif
  77.  
  78. #ifndef SOM_ODFacet_xh
  79. #include "Facet.xh"
  80. #endif
  81.  
  82. #ifndef SOM_ODFrame_xh
  83. #include "Frame.xh"
  84. #endif
  85.  
  86. #ifndef SOM_ODPartWrapper_xh
  87. #include "PartWrap.xh"
  88. #endif
  89.  
  90. #ifndef SOM_ODFrameFacetIterator_xh
  91. #include "FrFaItr.xh"
  92. #endif
  93.  
  94. #ifndef _SEUTILS_
  95. #include "SEUtils.h"
  96. #endif
  97.  
  98. #ifndef _ODUTILS_
  99. #include "ODUtils.h"
  100. #endif
  101.  
  102. #ifndef SOM_ODTransform_xh
  103. #include "Trnsform.xh"
  104. #endif
  105.  
  106. #ifndef _EXCEPT_
  107. #include "Except.h"
  108. #endif
  109.  
  110. #ifndef _ORDCOLL_
  111. #include "OrdColl.h"
  112. #endif
  113.  
  114. #ifndef SOM_ODWindow_xh
  115. #include <Window.xh>
  116. #endif
  117.  
  118. #ifndef __AEREGISTRY__
  119. #include <AERegistry.h>
  120. #endif
  121.  
  122. #ifndef SOM_ODShape_xh
  123. #include <Shape.xh>
  124. #endif
  125.  
  126. #ifndef __TEXTEDIT__
  127. #include <TextEdit.h>
  128. #endif
  129.  
  130. #ifndef _ODDEBUG_
  131. #include "ODDebug.h"    // Adkins -- added
  132. #endif
  133.  
  134. #ifndef _TEMPOBJ_
  135. #include "TempObj.h"
  136. #endif
  137.  
  138. #pragma segment PrtPrpAc
  139.  
  140. //==============================================================================
  141. // Constants
  142. //==============================================================================
  143.  
  144. //==============================================================================
  145. // Scalar Types
  146. //==============================================================================
  147.  
  148. //==============================================================================
  149. // Local Classes
  150. //==============================================================================
  151.  
  152. //==============================================================================
  153. // Global Variables
  154. //==============================================================================
  155.  
  156. //==============================================================================
  157. // Function Prototype
  158. //==============================================================================
  159.  
  160. //==============================================================================
  161. // AbsDrawPartPropAccessor
  162. //==============================================================================
  163.  
  164. //------------------------------------------------------------------------------
  165. // AbsDrawPartPropAccessor::AbsDrawPartPropAccessor
  166. //------------------------------------------------------------------------------
  167. AbsDrawPartPropAccessor::AbsDrawPartPropAccessor(DescType property,
  168.         ODObject* object)
  169. {
  170.     fProperty = property;
  171.     fObject = object;
  172. }
  173.  
  174. //------------------------------------------------------------------------------
  175. // AbsDrawPartPropAccessor::SetData
  176. //------------------------------------------------------------------------------
  177. void AbsDrawPartPropAccessor::SetData(AEDesc* data)
  178. {
  179.     ODUnused(data);
  180.     THROW(errAEEventNotHandled);
  181. }
  182.  
  183. //------------------------------------------------------------------------------
  184. // AbsDrawPartPropAccessor::GetData
  185. //------------------------------------------------------------------------------
  186. void AbsDrawPartPropAccessor::GetData(AEDesc* result)
  187. {
  188.     ODUnused(result);
  189.     THROW(errAEEventNotHandled);
  190. }
  191.  
  192. //------------------------------------------------------------------------------
  193. // AbsDrawPartPropAccessor::GetProperty
  194. //------------------------------------------------------------------------------
  195. DescType AbsDrawPartPropAccessor::GetProperty()
  196. {
  197.     return fProperty;
  198. }
  199.  
  200. //------------------------------------------------------------------------------
  201. // AbsDrawPartPropAccessor::GetObject
  202. //------------------------------------------------------------------------------
  203. ODObject* AbsDrawPartPropAccessor::GetObject()
  204. {
  205.     return fObject;
  206. }
  207.  
  208. //==============================================================================
  209. // DrawPartPropAccessor
  210. //==============================================================================
  211.  
  212. //------------------------------------------------------------------------------
  213. // DrawPartPropAccessor::DrawPartPropAccessor
  214. //------------------------------------------------------------------------------
  215.  
  216. DrawPartPropAccessor::DrawPartPropAccessor(DescType property, ODFrame* frame)
  217.     :AbsDrawPartPropAccessor(property, frame)
  218. {
  219. #ifdef TO_BE_DELETED
  220. //     fProperty = property;
  221. //     fPart = part;
  222. #endif // TO_BE_DELETED
  223. //    fContainedPart = kODNULL;
  224. }
  225.  
  226. //------------------------------------------------------------------------------
  227. // DrawPartPropAccessor::SetData
  228. //------------------------------------------------------------------------------
  229.  
  230. void DrawPartPropAccessor::SetData(AEDesc* data)
  231. {
  232. //    DescType    gotType;
  233. //    Size        actualSize;
  234. //    ODError    result;
  235.     Environment*    ev = somGetGlobalEnvironment();
  236.  
  237.     switch(this->GetProperty())
  238.     {
  239.         case pColor:
  240.         {
  241.             RGBColor color;
  242.             if (data->descriptorType == typeRGBColor)
  243.             {
  244.                 color = **(RGBColor**)data->dataHandle;
  245.             }
  246.             else
  247.             {
  248.                 AEDesc colorDesc;
  249.                 THROW_IF_ERROR(AECoerceDesc(data, typeRGBColor, &colorDesc));
  250.                 color = **(RGBColor**)colorDesc.dataHandle;
  251.                 AEDisposeDesc(&colorDesc);
  252.             }
  253.  
  254. //            OrderedCollectionIterator iter(this->GetDrawPart()->GetDisplayFrames(ev));
  255. //            for (ODFrame* frame = (ODFrame*)iter.First()
  256. //                    ;iter.IsNotComplete()
  257. //                    ;frame = (ODFrame*)iter.Next())
  258. //            {
  259. //                this->GetDrawPart()->SetBGColor2(ev, frame, color);
  260. //                frame->Invalidate(ev, (ODShape*)kODNULL, kODNULL);
  261. //            }
  262.             ODFrame* frame = this->GetFrame();
  263.             WASSERT( frame );
  264.             ODPartWrapper* wrapper = (ODPartWrapper*)frame->AcquirePart(ev);
  265.             // NOTE THAT THE CALL TO GetRealPart IS NOT SCRICTLY NECESSARY SINCE THE REAL
  266.             //    PART COULD HAVE BEEN GOTTEN FROM THE ODSEMANTICINTERFACE OBJECT ITSELF
  267.             //    AND PASSED ALONG SOMEWHERE BEFORE THIS METHOD WAS CALLED.
  268.             AppleTest_Container* drawPart = (AppleTest_Container*)wrapper->GetRealPart(ev);
  269.             drawPart->SetBGColor2(ev, frame, &color);
  270.             wrapper->ReleaseRealPart(ev);
  271.             ((ODPart*)wrapper)->Release(ev);
  272.             frame->Invalidate(ev, (ODShape*)kODNULL, kODNULL);
  273.             break;
  274.         }
  275.         default:
  276.             THROW(errAECantSupplyType);
  277.             break;
  278.     }
  279. }    // DrawPartPropAccessor::SetData()
  280.  
  281. //------------------------------------------------------------------------------
  282. // DrawPartPropAccessor::GetData
  283. //------------------------------------------------------------------------------
  284.  
  285. void DrawPartPropAccessor::GetData(AEDesc* objectData)
  286. {
  287.     ODError            result;
  288.     Environment*    ev = somGetGlobalEnvironment();
  289.     
  290.     switch(this->GetProperty())
  291.     {
  292.         case pName:
  293.         {
  294.             // this is the draw part for now
  295.             unsigned char* name = "\pDrawPart";
  296.             THROW_IF_ERROR(AECreateDesc(typeChar, (Ptr)&name[1], name[0],
  297.                     objectData));
  298.         }
  299.             break;
  300.  
  301.         case pBounds:
  302.         {
  303. //            OrderedCollectionIterator iter(this->GetDrawPart()->GetDisplayFrames(ev));
  304. //            ODFrame* frame = (ODFrame*)iter.First();
  305.             ODFrame* frame = this->GetFrame();
  306.             WASSERT( frame );
  307.             TempODShape shape = frame->AcquireFrameShape(ev, kODNULL); // DMc refcount - make temp
  308.         //    if(shape->IsRectangular())
  309.             {
  310.                 ODRect r;
  311.                 shape->GetBoundingBox(ev, &r);
  312.                 Rect qdR;
  313.                 r.AsQDRect(qdR);
  314.                 result = AECreateDesc(typeQDRectangle, (Ptr)&qdR, sizeof(qdR),
  315.                         objectData);
  316.                 THROW_IF_ERROR(result);
  317.             }
  318.         }
  319.             break;
  320.  
  321.         case pColor:
  322.         {
  323. //            OrderedCollectionIterator iter(this->GetDrawPart()->GetDisplayFrames(ev));
  324.                 // For now, assume first frame
  325. //            ODFrame* frame = (ODFrame*)iter.First();
  326.             ODFrame* frame = this->GetFrame();
  327.             WASSERT( frame );
  328.  
  329.             PartInfoRec* pInfo = (PartInfoRec *)frame->GetPartInfo(ev);
  330.             RGBColor theColor = pInfo->bgColor;
  331.             
  332. #ifdef TO_BE_DELETED
  333. //             for (ODFrame* frame = (ODFrame*)iter.First()
  334. //                     ;iter.IsNotComplete()
  335. //                     ;frame = (ODFrame*)iter.Next())
  336. //             {
  337. //                 PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo();
  338. //                 theColor = pInfo->bgColor;
  339. //             }
  340. //             
  341. #endif // TO_BE_DELETED
  342.  
  343.             result = AECreateDesc(typeRGBColor, (Ptr)&theColor, sizeof(theColor), objectData);
  344.             THROW_IF_ERROR(result);
  345.  
  346.             break;
  347.         }
  348.         default:
  349.             THROW(errAECantSupplyType);
  350.             break;
  351.     }
  352. }
  353.  
  354. //------------------------------------------------------------------------------
  355. // DrawPartPropAccessor::AcquireFrame
  356. //------------------------------------------------------------------------------
  357. ODFrame* DrawPartPropAccessor::GetFrame()
  358.     
  359. {
  360.     return (ODFrame*)AbsDrawPartPropAccessor::GetObject();
  361. }
  362.  
  363.  
  364. #ifdef TO_BE_DELETED
  365. // DMc refcount - comment out the lines below so refbal ignores them:
  366. // //------------------------------------------------------------------------------
  367. // // DrawPartPropAccessor::SetContainedPart
  368. // //------------------------------------------------------------------------------
  369. // void DrawPartPropAccessor::SetContainedPart(ODPart* containedPart)
  370. // {
  371. //     fContainedPart = containedPart;
  372. // }
  373. // 
  374. // //------------------------------------------------------------------------------
  375. // // DrawPartPropAccessor::GetContainedPart
  376. // //------------------------------------------------------------------------------
  377. // ODPart* DrawPartPropAccessor::GetContainedPart()
  378. // {
  379. //     return fContainedPart;
  380. // }
  381. #endif // TO_BE_DELETED
  382.  
  383. //==============================================================================
  384. // EmbeddedPartPropAccessor
  385. //==============================================================================
  386.  
  387. //------------------------------------------------------------------------------
  388. // EmbeddedPartPropAccessor::DrawPartPropAccessor
  389. //------------------------------------------------------------------------------
  390.  
  391. EmbeddedPartPropAccessor::EmbeddedPartPropAccessor(DescType property,
  392.         ODFrame* frame, AppleTest_Container* me)
  393.     :AbsDrawPartPropAccessor(property, frame)
  394. {
  395.     fDrawPart = me;
  396. }
  397.  
  398. //------------------------------------------------------------------------------
  399. // EmbeddedPartPropAccessor::GetThisPart
  400. //------------------------------------------------------------------------------
  401.  
  402. AppleTest_Container* EmbeddedPartPropAccessor::GetThisPart()
  403. {
  404.     return fDrawPart;
  405. }
  406.  
  407. //------------------------------------------------------------------------------
  408. // EmbeddedPartPropAccessor::SetData
  409. //------------------------------------------------------------------------------
  410.  
  411. static void MoveFacetTransform(ODFacet* facet, Point* desiredLocation,
  412.         ODPart* part)
  413. {
  414.     Environment*    ev = somGetGlobalEnvironment();
  415.     TempODTransform origXform = facet->AcquireExternalTransform(ev, kODNULL); // DMc refcount - make temp
  416.     TempODTransform newXForm = origXform->Copy(ev); // DMc refcount - make temp
  417.     Point curOffset = newXForm->GetQDOffset(ev);
  418.     Point scratch = *desiredLocation;
  419.     scratch.h -= curOffset.h;
  420.     scratch.v -= curOffset.v;
  421.  
  422.     ODPoint newDelta = *desiredLocation = scratch;
  423.     newXForm->MoveBy(ev, &newDelta);
  424.     facet->ChangeGeometry(ev, kODNULL, newXForm, kODNULL);
  425.     TempODShape clipShape = facet->AcquireClipShape(ev, kODNULL); // DMc refcount - make temp
  426.     facet->Invalidate(ev, (ODShape*) clipShape, kODNULL);
  427. }
  428.  
  429. void EmbeddedPartPropAccessor::SetData(AEDesc* data)
  430. {
  431. #if 0
  432. // DMc refcount - comment out lines so that refbal ignores these lines
  433. //     ODError            result;
  434. //     Environment*    ev = somGetGlobalEnvironment();
  435. // 
  436. //     ODFrame* targetFrame = this->AcquireFrame();        // the *contained* frame
  437. // 
  438. //     switch(this->GetProperty())
  439. //     {
  440. //         case pTranslation:
  441. //         {
  442. //         
  443. //                 // Get the old shape to invalidate
  444. //             ODShape* oldShape = targetFrame->AcquireFrameShape(ev, kODNULL)->Copy(ev);
  445. //             
  446. //                 // Make a new shape and set bounds
  447. //             ODShape* newShape = targetFrame->CreateShape(ev);
  448. //         
  449. //             AEDesc dPoint;
  450. //             result = AECoerceDesc(data, typeQDPoint, &dPoint); 
  451. //             THROW_IF_ERROR(result);
  452. //             Point thePoint = **(Point**)dPoint.dataHandle;
  453. //             AEDisposeDesc(&dPoint);
  454. // 
  455. //                 // Make a new shape and set bounds
  456. //             ODTransform* newTrans = targetFrame->CreateTransform(ev);
  457. //             newTrans->SetQDOffset(ev, &thePoint);
  458. //             newShape->Transform(ev, newTrans);
  459. // 
  460. //             ODFrameFacetIterator* facetIterator =
  461. //                     targetFrame->CreateFacetIterator(ev);
  462. //             for (ODFacet* facet = facetIterator->First(ev);
  463. //                 facetIterator->IsNotComplete(ev);
  464. //                 facet = facetIterator->Next(ev))
  465. //             {
  466. //                 // invalidate old frame shape
  467. //                 //oldShape->Transform(selection->transform);
  468. //                 targetFrame->Invalidate(ev, oldShape, kODNULL);
  469. //             
  470. //                 ODShape* newShapeCopy = newShape->Copy(ev);        // save to invalidate later
  471. //             
  472. //                 targetFrame->ChangeFrameShape(ev, newShape);    // already in frame coords
  473. //                 facet->ChangeGeometry(ev, kODNULL, newTrans);
  474. // 
  475. //                 // invalidate changed areas
  476. //                 //newShapeCopy->Transform(selection->transform);
  477. //                 //facet->AcquireFrame()->Invalidate(newShapeCopy);
  478. //                 targetFrame->Invalidate(ev, newShapeCopy);
  479. //                 delete newShapeCopy;
  480. //             
  481. //         //        AppleTest_Container* thisPart = (AppleTest_Container*)targetFrame->AcquirePart();
  482. //                 this->GetThisPart()->InvalidateSelection(ev, targetFrame);
  483. //                 //fPart->UpdateProxyRegion(selection);
  484. //                 //fPart->CreateProxySelectionBorder(selection);
  485. //                 this->GetThisPart()->ClipEmbeddedFrames(ev, targetFrame);
  486. //                 this->GetThisPart()->InvalidateSelection(ev, targetFrame);
  487. //             
  488. //                 this->GetThisPart()->AcquireStorageUnit(ev)->AcquireDraft(ev)->
  489. //                         SetChangedFromPrev(ev);
  490. //             }    
  491. //             delete oldShape;
  492. //             break;
  493. //         }
  494. //         case pBounds:
  495. //         {
  496. //             // Get the new rect
  497. //             AEDesc dRect;
  498. //             result = AECoerceDesc(data, typeQDRectangle, &dRect); 
  499. //             THROW_IF_ERROR(result);
  500. //             Rect usersRect = **(Rect**)dRect.dataHandle;
  501. //             AEDisposeDesc(&dRect);
  502. //             
  503. //             Point pt = *(Point*)&usersRect;
  504. // 
  505. //             // make the rect 0-based
  506. //             OffsetRect(&usersRect, -usersRect.left, -usersRect.top);
  507. //             
  508. //             ODShape* newShape = targetFrame->AcquireFrameShape(ev)->Copy(ev);
  509. //             ODRect usersODRect = usersRect;
  510. //             newShape->SetRectangle(ev, &usersODRect);
  511. //             targetFrame->ChangeFrameShape(ev, newShape);
  512. // 
  513. //             ODFrame* frame = this->AcquireFrame(ev);
  514. //             WASSERT( frame );
  515. // 
  516. //             ODFrameFacetIterator* fi = frame->CreateFacetIterator(ev);
  517. //             ODFacet* facet = fi->First(ev);
  518. //             MoveFacetTransform(facet, &pt, frame->AcquirePart(ev));
  519. //     
  520. //             Proxy* p = this->GetThisPart()->ProxyForFrame(ev, targetFrame);
  521. //     
  522. //             // !!! this is a single-facet hack
  523. //             p->transform->MoveBy(ev, pt);        
  524. //             this->GetThisPart()->UpdateProxyRegion(ev, p);
  525. //             this->GetThisPart()->CreateProxySelectionBorder(ev, p);
  526. //     
  527. //             targetFrame->AcquireContainingFrame(ev)->Invalidate(ev, (ODShape*)kODNULL, kODNULL);
  528. // 
  529. //             break;
  530.  
  531. #ifdef TO_BE_DELETED
  532. //             ODFrame* frame = this->AcquireFrame();
  533. //             ODFrameFacetIterator* fi = frame->CreateFrameFacetIterator(ev);
  534. //             ODFacet* facet = fi->First();
  535. //             WASSERT((fi->Next(), !fi->IsNotComplete()));
  536. //             ODTransform* transform = facet->AcquireExternalTransform();
  537. // 
  538. //             // NOTE: this is VERY dangerous, as I'm assuming that I'm contained
  539. //             // in a AppleTest_Container.  Won't work when other parts can contain! <eeh>
  540. // 
  541. //             ODFrame* outerFrame = frame->AcquireContainingFrame();
  542. //             AppleTest_Container* outerPart = (AppleTest_Container*)outerFrame->AcquirePart();
  543. //             Proxy* p = outerPart->ProxyForFrame(frame);
  544. // 
  545. //             Point newOffset = *(Point*)&usersRect;    //for the new xform
  546. //             Point curOffset = p->transform->GetQDOffset();
  547. //             
  548. //             newOffset.h -= curOffset.h;
  549. //             newOffset.v -= curOffset.v;
  550. //             short usersRight = usersRect.right - usersRect.left;
  551. //             short usersBottom = usersRect.bottom - usersRect.top;
  552. //             Rect xformedRect;        // goes into the new shape
  553. //             SetRect(&xformedRect, 0, 0, usersRight, usersBottom);
  554. // 
  555. //             ODTransform* newXform = new ODTransform;
  556. //             newXform->CopyFrom(transform);
  557. //             ODPoint xmpPt = newOffset;
  558. //             newXform->MoveBy(xmpPt);
  559. //             facet->ChangeGeometry(kODNULL, newXform);
  560. //             
  561. //             // !!! this is a single-facet hack
  562. //             p->transform->MoveBy(newOffset);
  563. //             ODTransform* newExternalXForm = new ODTransform;
  564. //             newExternalXForm->CopyFrom(p->transform);
  565. //             ODFrameFacetIterator* facets = p->frame->CreateFacetIterator();
  566. //             facets->First()->ChangeGeometry(kODNULL, newExternalXForm);
  567. //             delete facets;
  568. //             
  569. //             outerPart->UpdateProxyRegion(p);
  570. //             outerPart->CreateProxySelectionBorder(p);
  571. // 
  572. //             ODShape* shape = new ODShape();
  573. //             ODRect rect = xformedRect;
  574. //             shape->SetRectangle(&rect);
  575. //             frame->ChangeFrameShape(shape);
  576. //             facet->Invalidate(facet->AcquireClipShape());
  577. //             facet->ChangeGeometry(facet->AcquireFrame()->AcquireFrameShape()->Copy(), kODNULL);
  578. //             facet->GetContainingFacet()->Invalidate(kODNULL);
  579. // 
  580. //             break;
  581. #endif // TO_BE_DELETED
  582. //         }
  583. //         default:
  584. //             THROW(errAECantSupplyType);
  585. //             break;
  586. //     }
  587. #endif // 0
  588. }    // EmbeddedPartPropAccessor::SetData()
  589.  
  590. //------------------------------------------------------------------------------
  591. // EmbeddedPartPropAccessor::GetData
  592. //------------------------------------------------------------------------------
  593.  
  594. void EmbeddedPartPropAccessor::GetData(AEDesc* objectData)
  595. {
  596.     Environment*    ev = somGetGlobalEnvironment();
  597.     ODError            result;
  598.     ODFrame*         frame = this->GetFrame();
  599.  
  600.     switch(this->GetProperty())
  601.     {
  602.         case pTranslation:
  603.         {
  604.             WASSERT(false);        // should not be here
  605.             
  606.             Point thePoint;
  607.             { TempODTransform t = frame->AcquireInternalTransform(ev, kODNULL); // DMc refcount - make temp
  608.               thePoint = t->GetQDOffset(ev);
  609.             }
  610.  
  611.             result = AECreateDesc(typeQDPoint, (Ptr)&thePoint, sizeof(thePoint), objectData);
  612.             THROW_IF_ERROR(result);
  613.  
  614.             break;
  615.         }
  616.         case pBounds:
  617.         {
  618.                 // make a copy of frame's shape
  619.             TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL); // DMc refcount - make temp
  620.             TempODShape shape = frameShape->Copy(ev); // DMc refcount - make temp
  621.  
  622.             ODFrameFacetIterator* fi = frame->CreateFacetIterator(ev);
  623.             ODFacet* facet = fi->First(ev);
  624.             WASSERT((fi->Next(ev), !fi->IsNotComplete(ev)));
  625.             delete fi;
  626.             
  627.             // DMc - why does this code want two of these?
  628.             TempODTransform t1 = facet->AcquireExternalTransform(ev, kODNULL); // DMc refcount - make temp
  629.             TempODTransform t2 = facet->AcquireExternalTransform(ev, kODNULL); // DMc refcount - make temp
  630.  
  631.             shape->Transform(ev, (ODTransform*) t2);
  632.  
  633.                 // get the bounding box of the shape
  634.             ODRect theBounds;
  635.             shape->GetBoundingBox(ev, &theBounds);
  636.             ODReleaseObject(ev, shape); // DMc refcount - release instead of delete
  637.  
  638.                 // send it back to the user
  639.             Rect qdRect;
  640.             theBounds.AsQDRect(qdRect);
  641.             result = AECreateDesc(typeQDRectangle, (Ptr)&qdRect,
  642.                     sizeof(qdRect), objectData);
  643.             THROW_IF_ERROR(result);
  644.             break;
  645.         }
  646.         default:
  647.             THROW(errAECantSupplyType);
  648.             break;
  649.     }
  650. }    // EmbeddedPartPropAccessor::GetData
  651.  
  652. //------------------------------------------------------------------------------
  653. // EmbeddedPartPropAccessor::AcquirePart
  654. //------------------------------------------------------------------------------
  655.  
  656. ODFrame* EmbeddedPartPropAccessor::GetFrame()
  657. {
  658.     return (ODFrame*)AbsDrawPartPropAccessor::GetObject();
  659. }
  660.  
  661. //==============================================================================
  662. // FramePropAccessor
  663. //==============================================================================
  664.  
  665. //------------------------------------------------------------------------------
  666. // FramePropAccessor::DrawPartPropAccessor
  667. //------------------------------------------------------------------------------
  668.  
  669. #ifdef TO_BE_DELETED
  670. // DMc refcount - comment out lines so refbal ignores them
  671. // FramePropAccessor::FramePropAccessor(DescType property, ODFrame* frame)
  672. //     :AbsDrawPartPropAccessor(property, frame)
  673. // {
  674. // }
  675. #endif // TO_BE_DELETED
  676.  
  677. //------------------------------------------------------------------------------
  678. // FramePropAccessor::GetFrame
  679. //------------------------------------------------------------------------------
  680. #ifdef TO_BE_DELETED
  681. // DMc refcount - comment out lines so refbal ignores them
  682. // ODFrame* FramePropAccessor::GetFrame()
  683. // {
  684. //     return (ODFrame*)AbsDrawPartPropAccessor::GetObject();
  685. // }
  686. #endif // TO_BE_DELETED
  687.  
  688. //------------------------------------------------------------------------------
  689. // FramePropAccessor::SetData
  690. //------------------------------------------------------------------------------
  691.  
  692. #ifdef TO_BE_DELETED
  693. // DMc refcount - comment out lines so refbal ignores them
  694. // void FramePropAccessor::SetData(AEDesc* data)
  695. // {
  696. //     DescType        gotType;
  697. //     ODSize            actualSize;
  698. //     ODError            result;
  699. //     Point             thePoint = { 0, 0 };
  700. //     Environment*    ev = somGetGlobalEnvironment();
  701. // 
  702. //             
  703. //     switch(this->GetProperty())
  704. //     {
  705. //         case pBounds:
  706. //         {
  707. //             // Get the new rect
  708. //             AEDesc dRect;
  709. //             result = AECoerceDesc(data, typeQDRectangle, &dRect); 
  710. //             THROW_IF_ERROR(result);
  711. //             Rect usersRect = **(Rect**)dRect.dataHandle;
  712. //             AEDisposeDesc(&dRect);
  713. // 
  714. //             ODFrameFacetIterator* fi =
  715. //                     new ODFrameFacetIterator(this->AcquireFrame());
  716. //             ODFacet* facet = fi->First();
  717. //             WASSERT((fi->Next(), !fi->IsNotComplete()));
  718. //             ODTransform* transform = facet->AcquireExternalTransform(ev);
  719. // 
  720. //             // NOTE: this is VERY dangerous, as I'm assuming that I'm contained
  721. //             // in a AppleTest_Container.  Won't work when other parts can contain! <eeh>
  722. // 
  723. //             ODFrame* outerFrame = this->AcquireFrame(ev)->AcquireContainingFrame(ev);
  724. //             AppleTest_Container* outerPart = (AppleTest_Container*)outerFrame->AcquirePart();
  725. //             Proxy* p = outerPart->ProxyForFrame(this->AcquireFrame());
  726. // 
  727. //             Point newOffset = *(Point*)&usersRect;    //for the new xform
  728. //     //        Point curOffset = transform->GetQDOffset();
  729. //             Point curOffset = p->transform->GetQDOffset();
  730. //             
  731. //             newOffset.h -= curOffset.h;
  732. //             newOffset.v -= curOffset.v;
  733. //             short usersRight = usersRect.right - usersRect.left;
  734. //             short usersBottom = usersRect.bottom - usersRect.top;
  735. //             Rect xformedRect;        // goes into the new shape
  736. //             SetRect(&xformedRect, 0, 0, usersRight, usersBottom);
  737. // 
  738. //             ODTransform* newXform = new ODTransform;
  739. //             newXform->CopyFrom(transform);
  740. //             ODPoint xmpPt = newOffset;
  741. //             newXform->MoveBy(xmpPt);
  742. //             facet->ChangeGeometry(kODNULL, newXform);
  743. // 
  744. //             
  745. //             // !!! this is a single-facet hack
  746. //             p->transform->MoveBy(newOffset);
  747. //             ODTransform* newExternalXForm = p->transform->Copy(Ev);
  748. //             ODFrameFacetIterator* facets = p->frame->CreateFacetIterator();
  749. //             facets->First()->ChangeGeometry(kODNULL, newExternalXForm);
  750. //             delete facets;
  751. //             
  752. //             outerPart->UpdateProxyRegion(p);
  753. //             outerPart->CreateProxySelectionBorder(p);
  754. // 
  755. //             ODShape* shape = facet->CreateShape(ev);
  756. //             ODRect rect = xformedRect;
  757. //             shape->SetRectangle(&rect);
  758. //             this->AcquireFrame()->ChangeFrameShape(shape);
  759. //             facet->Invalidate(facet->AcquireClipShape());
  760. //             facet->ChangeGeometry(facet->AcquireFrame()->AcquireFrameShape()->Copy(), kODNULL);
  761. //             facet->GetContainingFacet()->Invalidate(kODNULL);
  762. //             
  763. #ifdef TO_BE_DELETED
  764. //             this->AcquireFrame()->AcquirePart()->Draw(facet, shape);
  765. //             ODFrame* containerF = this->AcquireFrame()->AcquireContainingFrame();
  766. //             if (containerF)
  767. //             {
  768. //                 ODPart* container = containerF->AcquirePart();
  769. //                 ODEmbeddedFramesIterator* fi =
  770. //                         container->CreateEmbeddedFramesIterator();
  771. //                 for(ODFrame* frm = fi->First(); fi->IsNotComplete();
  772. //                         frm = fi->Next())
  773. //                 {
  774. //                     frm->Invalidate(frm->AcquireUsedShape());
  775. //                     //container->Draw((ODFacet*)kODNULL,
  776. //                     //        (ODShape*)kODNULL);
  777. //                 }
  778. //             }
  779. #endif // TO_BE_DELETED
  780.  
  781.  
  782. #ifdef TO_BE_DELETED
  783. //             // xform it using the current external xform
  784. //             ODFrameFacetIterator* fi =
  785. //                     new ODFrameFacetIterator(this->AcquireFrame());
  786. //             ODFacet* facet = fi->First();
  787. //             WASSERT((fi->Next(), !fi->IsNotComplete()));
  788. //             ODShape* shape = new ODShape();
  789. //             ODRect rect = usersRect;
  790. //             shape->SetRectangle(&rect);
  791. //             ODTransform* transform = facet->AcquireExternalTransform();
  792. //             shape->Transform(transform);
  793. //             
  794. //             ODRect transformedRect;
  795. //             shape->GetBoundingBox(&transformedRect);
  796. // 
  797. //             // subtract transformed from incoming to get new pt, and make
  798. //             // it into the new transform
  799. //             Point pt;
  800. //             pt.h = (short)(transformedRect.left - transformedRect.left);
  801. //             pt.v = (short)(transformedRect.top - transformedRect.top);
  802. //             ODTransform* newXform = new ODTransform;
  803. //             newXform->CopyFrom(transform);
  804. //             ODPoint xmpPt = pt;
  805. //             newXform->MoveBy(xmpPt);
  806. //             facet->ChangeGeometry(kODNULL, newXform);
  807. // 
  808. //             // use xformed rect to set new shape (shape is already set up?)
  809. //             // That is, set the facet's shape to be the new one?
  810. //             this->AcquireFrame()->ChangeFrameShape(shape);
  811. //             facet->ResetClipShape();
  812. #endif // TO_BE_DELETED
  813.  
  814. //             break;
  815. //         }
  816. //         default:
  817. //             THROW(errAEEventNotHandled);
  818. //             break;
  819. //     }
  820. // }
  821. #endif // TO_BE_DELETED
  822.  
  823. //------------------------------------------------------------------------------
  824. // FramePropAccessor::GetData
  825. //------------------------------------------------------------------------------
  826.  
  827. #ifdef TO_BE_DELETED
  828. // void FramePropAccessor::GetData(AEDesc* objectData)
  829. // {
  830. //     switch(this->GetProperty())
  831. //     {
  832. //         case pBounds:
  833. //         {
  834. //             TempODFrame tempFrame = this->AcquireFrame();
  835. //             TempODShape theShape = tempFrame->AcquireFrameShape();
  836. //             ODRect bounds;
  837. //             theShape->GetBoundingBox(&bounds);
  838. //             Rect qdBounds;
  839. //             bounds.AsQDRect(qdBounds);
  840. //             THROW_IF_ERROR(AECreateDesc(typeQDRectangle, (Ptr)&qdBounds,
  841. //                     sizeof(qdBounds), objectData));
  842. //             break;
  843.  
  844. #ifdef TO_BE_DELETED
  845. //             ODRect theBounds;
  846. //             ODFrameFacetIterator* fi =
  847. //                     new ODFrameFacetIterator(this->GetEmbeddedFrame());
  848. //             ODFacet* facet = fi->First();
  849. //             WASSERT((fi->Next(), !fi->IsNotComplete()));
  850. // 
  851. //                 // make a copy of frame's shape
  852. //             ODShape* shape = new ODShape();
  853. //             ODShape* embeddedFrameShape = this->GetEmbeddedFrame()->AcquireFrameShape();
  854. //             TempODShape tempEmFrShape = embeddedFrameShape;
  855. //             shape->CopyFrom(embeddedFrameShape);
  856. //             
  857. //             {ODTransform* transform = facet->AcquireExternalTransform();
  858. //              shape->Transform(transform);
  859. //              transform->Release();
  860. //             }
  861. //             
  862. //                 // get the bounding box of the shape
  863. //             shape->GetBoundingBox(&theBounds);
  864. //             delete shape;
  865. // 
  866. //             Rect r;
  867. //             theBounds.AsQDRect(r);
  868. //             THROW_IF_ERROR(AECreateDesc(typeQDRectangle, (Ptr)&r,
  869. //                     sizeof(r), objectData));
  870. #endif // TO_BE_DELETED
  871. //         }
  872. //         default:
  873. //             THROW(errAEEventNotHandled);
  874. //             break;
  875. //     }
  876. // }
  877.  
  878. #endif // TO_BE_DELETED
  879.